package 面试刷题.小米;

import java.util.Scanner;

/**
 * 归并排序
 */
public class ch05_有序数组合并 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        int[] res = new int[n + m];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }
        int ai = 0, bi = 0, i = 0;
        while (ai < n && bi < m) {
            if (b[bi] < a[ai]) {
                res[i++] = b[bi++];
            } else {
                res[i++] = a[ai++];
            }
        }
        while (ai < n) {
            res[i++] = a[ai++];
        }
        while (bi < m) {
            res[i++] = b[bi++];
        }
        for (int re : res) {
            System.out.print(re + " ");
        }
    }
}
